import 'package:permission_handler/permission_handler.dart';

/// 权限申请
class BasePermissionUtils {

  BasePermissionUtils._();

  /// 申请必须要的权限
  static Future<bool> handlerRequirePermission() async {
    PermissionStatus cameraStatus = await Permission.camera.status;
    PermissionStatus storageStatus = await Permission.storage.status;
    if ( cameraStatus.isGranted == true && storageStatus.isGranted ) {
      return Future.value(true);
    }
    Map<Permission, PermissionStatus> statuses = await [Permission.storage, Permission.camera].request();
    if ( statuses[Permission.storage].isGranted == true && statuses[Permission.camera].isGranted == true ) {
      return Future.value(true);
    }
    return Future.value(false);
  }

}
